package com.atguigui.leetcode;

/**
 * 944.删列造序
 * Project: leetcode
 * Package: com.atguigui.leetcode
 * Version: 1.0
 * <p>
 * Created by WJX on 2022/5/12 9:00
 */
public class P944DeleteColumnsToMakeSorted {
    public static void main(String[] args) {
        Solution solution = new P944DeleteColumnsToMakeSorted().new Solution();
        String[] str = {"rrjk", "furt", "guzm"};
        System.out.println(solution.minDeletionSize(str));
        // TO TEST
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int minDeletionSize(String[] strs) {

            int length = strs[0].length();
            int result = 0;

            for (int i = 0; i < length; i++) {
                char a = ' ';
                for (int j = 0; j < strs.length; j++) {
                    char str = strs[j].charAt(i);
                    if (a == 32 || a < str) {
                        a = str;
                    } else if (a > str) {
                        result++;
                        break;
                    }
                }
            }

            return result;
        }
    }
}
